<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../Templates/InnerSystemTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="head-title">
        <title>Add Sale Lead | Merlion's ERP System</title>
    </ui:define>
    
    
    <ui:define name="content">
        <h:form>
            <p:panel id="panel" header="Add New Sale Lead"> 
                <p:ajaxStatus style="width:16px;height:16px;">   
                    <f:facet name="start">   
                        <p:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" /> 
                    </f:facet> 
 
                    <f:facet name="complete">   
                        <h:outputText value="" />   
                    </f:facet>   
                </p:ajaxStatus> 
 
                <p:messages /> 
 
                <h:panelGrid columns="3" cellpadding="10"> 
                    
                    <h:outputLabel for="saleLeadName" style="font-weight: bold" value="Sale Lead Name: " /> 
                    <p:inputText value="#{saleLeadManagerBean.saleLeadName}" required="true" label="Sale Lead Name" requiredMessage="Sale Lead Name is required." id="saleLeadName"> 
                        
                    </p:inputText> 
                    <p:message for="saleLeadName" /> 
                    
                    <h:outputLabel for="registrationNumber" style="font-weight: bold" value="Registration Number: " /> 
                    <p:inputText required="true" label="registrationNumber" requiredMessage="Registration Number is required." id="registrationNumber" value="#{saleLeadManagerBean.registrationNumber}"> 
                        
                    </p:inputText> 
                    <p:message for="registrationNumber" /> 

                    <h:outputLabel for="address" style="font-weight: bold" value="Address: " /> 
                    <p:inputText required="true" label="address" requiredMessage="Address is required." id="address" value="#{saleLeadManagerBean.address}">                         
                    </p:inputText> 
                    <p:message for="address" /> 
                    
                    <h:outputLabel for="customerType" style="font-weight: bold" value="Customer Type: " /> 
                    <h:selectOneMenu id ="customerType" value="#{saleLeadManagerBean.customerType}">
                        <f:selectItem itemValue="WholeSale" itemLabel="Whole Sale" id="wholeSale" />
                        <f:selectItem itemValue="DirectSale" itemLabel="Direct Sale" id="directSale" />
                    </h:selectOneMenu>
                    
                    <p:message for="customerType" />
                    
                
                
                <h:dataTable value="#{saleLeadManagerBean.reps}" var="rep">
                    <p:column sortBy="#{rep.name}" filterBy="#{rep.name}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Name" /> 
                        </f:facet> 
                        <h:outputText value="#{rep.name}" /> 
                    </p:column>
                    
                    <p:column sortBy="#{rep.NRIC}" filterBy="#{rep.NRIC}"> 
                        <f:facet name="header"> 
                            <h:outputText value="NRIC" /> 
                        </f:facet> 
                        <h:outputText value="#{rep.NRIC}" /> 
                    </p:column>
                    
                    <p:column sortBy="#{rep.email}" filterBy="#{rep.email}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Email" /> 
                        </f:facet> 
                        <h:outputText value="#{rep.email}" /> 
                    </p:column>
                    
                    <p:column sortBy="#{rep.contactNumber}" filterBy="#{rep.contactNumber}"> 
                        <f:facet name="header"> 
                            <h:outputText value="Contact Number" /> 
                        </f:facet> 
                        <h:outputText value="#{rep.contactNumber}" /> 
                    </p:column>
                </h:dataTable>
                <p:commandButton value="Add new Representative" actionListener="#{saleLeadManagerBean.addRep}" />
                </h:panelGrid>
                
                <p:commandButton id="btn" value="Save New Sale Lead" update="panel" actionListener="#{saleLeadManagerBean.saveNewSaleLead}" ajax="true" />
                <p:commandButton value="Clear" type="reset"/>
            </p:panel> 
        </h:form>
    </ui:define>

</ui:composition>
